home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.x
- Path: uunet!think.com!mips!msi!dcmartin
- From: "David C. Carver" <dcc@Athena.MIT.EDU>
- Subject: v16i109: vex.v2r2 patch #3, Patch3, Part01/01
- Message-ID: <1992Mar5.215838.9953@msi.com>
- Originator: dcmartin@fascet
- Sender: dcmartin@msi.com (David C. Martin - Moderator)
- Organization: Molecular Simulations, Inc.
- References: <csx-16i109-vex.v2r2@uunet.UU.NET>
- Date: Thu, 5 Mar 1992 21:58:38 GMT
- Approved: dcmartin@msi.com
-
- Submitted-by: "David C. Carver" <dcc@Athena.MIT.EDU>
- Posting-number: Volume 16, Issue 109
- Archive-name: vex.v2r2/patch3
- Patch-To: vex.v2r2: Volume 16, Issue 52
-
- Xv2r2 Patch #3
-
- This patch:
-
- This patch adds a program called eset to
-
-
- mit/extensions/xv/test
-
- and modifies the corresponding Imakefile to build it. The program eset
- allows users to query and set a port's encoding attribute.
-
- To apply this patch:
-
- cd to the top of the source tree (to the directory containing the "mit"
- and "contrib" subdirectories) and do:
-
- patch -p -s < ThisFile
-
- Patch will work silently unless an error occurs. You will likely get
- two warning messages, which can be ignored:
-
- mkdir: mit: File exists
-
- If you want to watch patch do its thing, leave out the "-s" argument to patch.
-
- After applying this patch:
-
- You need to cd to mit/extensions/xv/test and say
-
- make Makefile
- make
-
- Prereq: xv-patch-level-2
-
- *** /tmp/XVPATCHLEVEL.1 Mon Mar 2 11:03:18 1992
- --- mit/XVPATCHLEVEL Mon Mar 2 11:04:37 1992
- ***************
- *** 2 ****
- ! VERSION xv-patch-level-2
- --- 2 ----
- ! VERSION xv-patch-level-3
-
- *** mit/extensions/xv/test/Imakefile.0 Thu Dec 12 12:01:18 1991
- --- mit/extensions/xv/test/Imakefile Mon Mar 2 11:26:59 1992
- ***************
- *** 31,42 ****
- XVT8SRCS = xvt8.c
- XVT8OBJS = xvt8.o
-
- SRCS = $(XVT1SRCS) $(XVT2SRCS) $(XVT3SRCS) $(XVT4SRCS) $(XVT5SRCS) \
- ! $(XVT6SRCS) $(XVT7SRCS) $(XVT8SRCS) $(XVT9SRCS) $(XVT10SRCS)
- OBJS = $(XVT1OBJS) $(XVT2OBJS) $(XVT3OBJS) $(XVT4OBJS) $(XVT5OBJS) \
- ! $(XVT6OBJS) $(XVT7OBJS) $(XVT8OBJS) $(XVT9OBJS) $(XVT10OBJS)
-
- ! all:: xvt1 xvt2 xvt3 xvt4 xvt5 xvt6 xvt7 xvt8
-
- SingleProgramTarget(xvt1, $(XVT1OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
- SingleProgramTarget(xvt2, $(XVT2OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
- --- 31,45 ----
- XVT8SRCS = xvt8.c
- XVT8OBJS = xvt8.o
-
- + ESETSRCS = eset.c
- + ESETOBJS = eset.o
- +
- SRCS = $(XVT1SRCS) $(XVT2SRCS) $(XVT3SRCS) $(XVT4SRCS) $(XVT5SRCS) \
- ! $(XVT6SRCS) $(XVT7SRCS) $(XVT8SRCS) $(ESETSRCS) $(XVT10SRCS)
- OBJS = $(XVT1OBJS) $(XVT2OBJS) $(XVT3OBJS) $(XVT4OBJS) $(XVT5OBJS) \
- ! $(XVT6OBJS) $(XVT7OBJS) $(XVT8OBJS) $(ESETOBJS) $(XVT10OBJS)
-
- ! all:: xvt1 xvt2 xvt3 xvt4 xvt5 xvt6 xvt7 xvt8 eset
-
- SingleProgramTarget(xvt1, $(XVT1OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
- SingleProgramTarget(xvt2, $(XVT2OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
- ***************
- *** 46,51 ****
- --- 49,55 ----
- SingleProgramTarget(xvt6, $(XVT6OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
- SingleProgramTarget(xvt7, $(XVT7OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
- SingleProgramTarget(xvt8, $(XVT8OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
- + SingleProgramTarget(eset, $(ESETOBJS), $(XVLIBPATH), -lXv -lXext -lX11)
-
- xvt1: $(XVT1LIBS)
- xvt2: $(XVT2LIBS)
- ***************
- *** 55,59 ****
- --- 59,64 ----
- xvt6: $(XVT6LIBS)
- xvt7: $(XVT7LIBS)
- xvt8: $(XVT8LIBS)
- + eset: $(ESETLIBS)
-
- DependTarget()
-
- *** mit/extensions/xv/test/eset.c.0 Mon Mar 2 10:19:49 1992
- --- mit/extensions/xv/test/eset.c Mon Mar 2 09:48:07 1992
- ***************
- *** 0 ****
- --- 1,344 ----
- + /***********************************************************
- + Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
- + and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
- +
- + All Rights Reserved
- +
- + Permission to use, copy, modify, and distribute this software and its
- + documentation for any purpose and without fee is hereby granted,
- + provided that the above copyright notice appear in all copies and that
- + both that copyright notice and this permission notice appear in
- + supporting documentation, and that the names of Digital or MIT not be
- + used in advertising or publicity pertaining to distribution of the
- + software without specific, written prior permission.
- +
- + DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- + ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- + DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- + ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- + WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- + SOFTWARE.
- +
- + ******************************************************************/
- + /*
- + ** File:
- + **
- + ** eset.c --- Xv test program to set encoding
- + **
- + ** Author:
- + **
- + ** David Carver (Digital Workstation Engineering/Project Athena)
- + **
- + ** Revisions:
- + **
- + ** 26.02.92 Carver
- + ** - first version
- + **
- + */
- + #include <stdio.h>
- + #include <X11/Xlib.h>
- + #include <X11/Xutil.h>
- + #include <X11/extensions/Xvlib.h>
- +
- +
- + main(argc, argv)
- + int argc;
- + char *argv[];
- + {
- + char chr;
- + int ii, jj, kk, ll, status, mask, nitems;
- + unsigned int actual_w, actual_h;
- + int screen;
- +
- + Display *dpy;
- + Visual *vis,*def_vis;
- + XVisualInfo *p_vis_info, vis_info_temp;
- + XGCValues gc_attr;
- + GC gc;
- + XSetWindowAttributes win_attr;
- + Window root,main_win;
- + Colormap def_cmap;
- + XEvent event;
- +
- + unsigned long version, revision;
- + unsigned long nAdaptors, nEncodings;
- + XvAdaptorInfo *pAdaptors, *pAdaptor;
- + XvEncodingInfo *pEncoding, *pEncodings;
- + XvPortID port;
- + XvEncodingID encoding, old_encoding;
- + XvEvent *pe;
- + float rate;
- + Atom encoding_atom;
- + char *encoding_name;
- +
- + unsigned long vis_id;
- + unsigned long depth;
- + unsigned int evb, erb, mop;
- +
- + dpy = XOpenDisplay(0);
- + if (!dpy)
- + {
- + printf("\n Couldn't open display\n");
- + printf("\n eset terminated\n");
- + exit();
- + }
- +
- + screen = XDefaultScreen(dpy);
- + def_vis = XDefaultVisual(dpy, screen);
- + def_cmap = XDefaultColormap(dpy, screen);
- + root = XDefaultRootWindow(dpy);
- +
- + status = XvQueryExtension(dpy, &version, &revision, &mop, &evb, &erb);
- +
- + if (status != Success)
- + {
- + printf("\n The Xv Extension is not installed.\n");
- + printf("\n eset terminated\n");
- + exit();
- + }
- +
- + printf("\n Xv V%01d.%d\n", version, revision);
- +
- + XvQueryAdaptors(dpy, root, &nAdaptors, &pAdaptors);
- +
- + if (!nAdaptors)
- + {
- + printf("\n Your display has no video adaptors.\n");
- + printf("\n eset terminated\n");
- + exit();
- + }
- +
- + if (!Setup(argc, argv, nAdaptors, pAdaptors,
- + &port, &depth, &vis_id))
- + {
- + printf("\n Setup failed.\n");
- + printf("\n eset terminated\n");
- + exit();
- + }
- +
- +
- + XvQueryEncodings(dpy, port, &nEncodings, &pEncodings);
- +
- + encoding_atom = XInternAtom(dpy,"XV_ENCODING",False);
- +
- + XvGetPortAttribute(dpy, port,
- + encoding_atom, (int *)&encoding);
- +
- + pEncoding = pEncodings;
- + for (jj=0; jj<nEncodings; jj++)
- + {
- + if (encoding == pEncoding->encoding_id)
- + {
- + printf("\n");
- + printf(" Current port encoding is `%s'\n", pEncoding->name);
- + }
- + pEncoding++;
- + }
- +
- +
- + printf("\n");
- + printf(" The encodings supported by this adaptor are:\n");
- + printf("\n");
- + pEncoding = pEncodings;
- + for (jj=0; jj<nEncodings; jj++)
- + {
- + printf(" %2d: %s\n", pEncoding->encoding_id, pEncoding->name);
- + pEncoding++;
- + }
- +
- + for (;;)
- + {
- + printf("\n");
- + printf("Select encoding number: ");
- + scanf("%d",&encoding);
- +
- + pEncoding = pEncodings;
- + for (jj=0; jj<nEncodings; jj++)
- + {
- +
- + if (encoding == pEncoding->encoding_id)
- + {
- + encoding_name = pEncoding->name;
- + break;
- + }
- + pEncoding++;
- + }
- +
- + if (jj <= nEncodings) break;
- +
- + printf("\n Invalid encoding selected");
- + }
- +
- + encoding_atom = XInternAtom(dpy,"XV_ENCODING",False);
- +
- + XvSelectPortNotify(dpy, port, True);
- +
- + XvSetPortAttribute(dpy, port, encoding_atom, encoding);
- +
- + while (1)
- + {
- + XNextEvent(dpy, &event);
- + if (event.type == evb + XvPortNotify)
- + {
- + pe = (XvEvent *)&event;
- +
- + if (pe->xvport.attribute == encoding_atom)
- + {
- + printf("\n Port encoding changed to %s\n", encoding_name);
- + }
- + else
- + printf(" Got unexpected port notify event\n");
- + break;
- + }
- + }
- +
- + }
- +
- +
- +
- + Setup(argc, argv, nAdaptors, pAdaptors, p_port, p_depth, p_vis_id)
- + int argc;
- + char *argv[];
- + unsigned long nAdaptors;
- + XvAdaptorInfo *pAdaptors;
- + unsigned long *p_port;
- + unsigned long *p_depth;
- + unsigned long *p_vis_id;
- + {
- + int ii, jj;
- + XvAdaptorInfo *pAdaptor;
- + XvFormat *pFormat;
- + int adaptor, port, depth, visual_id;
- +
- + adaptor = port = depth = visual_id = -1;
- +
- + /* LOOK THROUGH COMMAND LINE ARGUMENTS */
- +
- + for ( ii = 1; ii < argc; ii++ )
- + {
- + if (strcmp( argv[ii], "-adaptor") == 0)
- + {
- + if(++ii < argc)
- + adaptor = atoi(argv[ii]);
- + else
- + UseMsg(argv);
- + }
- + else if (strcmp( argv[ii], "-port") == 0)
- + {
- + if(++ii < argc)
- + port = atoi(argv[ii]);
- + else
- + UseMsg(argv);
- + }
- + else if (strcmp( argv[ii], "-depth") == 0)
- + {
- + if(++ii < argc)
- + depth = atoi(argv[ii]);
- + else
- + UseMsg(argv);
- + }
- + else if (strcmp( argv[ii], "-visual") == 0)
- + {
- + if(++ii < argc)
- + visual_id = atoi(argv[ii]);
- + else
- + UseMsg(argv);
- + }
- + else if (strcmp( argv[ii], "-help") == 0)
- + {
- + UseMsg(argv);
- + }
- + }
- +
- + if (adaptor < 0)
- + {
- + pAdaptor = pAdaptors;
- + }
- + else
- + {
- + if (adaptor > nAdaptors)
- + {
- + printf("\n Adaptor #%d doesn't exist.\n", adaptor);
- + return False;
- + }
- + pAdaptor = pAdaptors+(adaptor-1);
- + }
- +
- + if (port < 0)
- + {
- + port = pAdaptor->base_id;
- + }
- + else
- + {
- + if (port > pAdaptor->num_ports)
- + {
- + printf("\n Port #%d doesn't exist for adaptor #%d.\n",
- + port, adaptor);
- + return False;
- + }
- + }
- +
- + pFormat = pAdaptor->formats;
- +
- + if (depth < 0)
- + {
- + depth = pFormat->depth;
- + }
- + else
- + {
- + for (ii=0; ii<pAdaptor->num_formats; ii++)
- + {
- + if (pFormat->depth == depth) break;
- + pFormat++;
- + }
- +
- + if (ii >= pAdaptor->num_formats)
- + {
- + printf("\n Depth %d not supported by adaptor.\n", depth);
- + return False;
- + }
- + }
- +
- + if (visual_id < 0)
- + {
- + visual_id = pFormat->visual_id;
- + }
- + else
- + {
- +
- + pFormat = pAdaptor->formats;
- +
- + for (ii=0; ii<pAdaptor->num_formats; ii++)
- + {
- + if ((pFormat->visual_id == visual_id) && pFormat->depth == depth)
- + break;
- + pFormat++;
- + }
- +
- + if (ii >= pAdaptor->num_formats)
- + {
- + printf("\n Visual-id %d at depth %d not supported by adaptor.\n",
- + depth, visual_id);
- + return False;
- + }
- + }
- +
- + *p_port = port;
- + *p_depth = depth;
- + *p_vis_id = visual_id;
- +
- + return True;
- + }
- +
- + UseMsg(argv)
- + char *argv[];
- + {
- +
- + printf("use: %s [option]\n", argv[0]);
- + printf("\t-adaptor # adaptor number\n");
- + printf("\t-port # port (XID)\n");
- + printf("\t-depth # drawable depth (planes)\n");
- + printf("\t-visual # drawable visual (id)\n");
- + exit();
- + }
-
- --
- --
- Molecular Simulations, Inc. mail: dcmartin@msi.com
- 796 N. Pastoria Avenue uucp: uunet!dcmartin
- Sunnyvale, California 94086 at&t: 408/522-9236
-